package tds.model20.version2;

import java.util.ArrayList;
import java.util.List;

/**
 * @Company 杭州先锋电子技术股份有限公司
 * @ClassName Folder
 * @Description 文件夹（Comosite）,容器节点
 * @author tds
 * @Date 2020/2/5 17:44
 * @version 1.0.0
 */
public class Folder implements AbstractFile {

    private String name;

    private List<AbstractFile> children = new ArrayList<>();

    public Folder(String name) {
        this.name = name;
    }

    @Override
    public void killVirus() {
        System.out.println("开始查杀文件" + name);
        for (AbstractFile child : children){
            child.killVirus();
        }
    }

    @Override
    public void add(AbstractFile file) {
        children.add(file);
    }

    @Override
    public void remove(AbstractFile file) {
        children.remove(file);
    }
}
